{% macro render_field(field, after="") %}
<div class="row">
  {{ field.label }}{{ field(**kwargs)|safe }}
  {% if after %} {{ after }}{% endif %}
  {% if field.errors %}
  <ul class="errors">
    {% for error in field.errors %}
    <li>{{ error }}</li>
    {% endfor %}
  </ul>
  {% endif %}
</div>
{% endmacro %}

{% macro render_field_invert(field, after="") %}
<div class="row">
  {{ field(**kwargs)|safe }}{{ field.label }}
  {% if after %} {{ after }}{% endif %}
  {% if field.errors %}
  <ul class="errors">
    {% for error in field.errors %}
    <li>{{ error }}</li>
    {% endfor %}
  </ul>
  {% endif %}
</div>
{% endmacro %}

{% macro render_field_in_row(field, after="", escape_after=False) %}
<tr>
    <td>{{ field.label }}</td>
    <td>{{ field(**kwargs)|safe }}</td>

    {% if escape_after %}
    {% autoescape off%} {% if after %} <td>{{ after }}</td>{% endif %} {% endautoescape %}
    {% else %}
    {% if after %} <td>{{ after }}</td>{% endif %}
    {% endif %}

    {% if field.errors %}
    <td>{% for error in field.errors %}{{ error }}<br />{% endfor %}</td>
    {% endif %}
</tr>
{% endmacro %}
